
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "cmsis_os2.h"
#include "ohos_init.h"

/**
 * @brief Callback for Timer1 triggering
 *
 */
void Timer1Callback(void)
{
    printf("This is Timer1Callback!\n");
}

/**
 * @brief Callback for Timer2 triggering
 *
 */
void Timer2Callback(void)
{
    printf("This is Timer2Callback!\n");
}

/**
 * @brief Main Entry of the Timer Example
 *
 */
static void TimerExample(void)
{
    osTimerId_t id1, id2;
    uint32_t timerDelay;
    osStatus_t status;

    id1 = osTimerNew(Timer1Callback, osTimerPeriodic, NULL, NULL);
    if (id1 != NULL) {

        timerDelay = 1000U;

        status = osTimerStart(id1, timerDelay);
        if (status != osOK) {
            printf("Failed to start Timer1!\n");
        }
    }

    id2 = osTimerNew(Timer2Callback, osTimerPeriodic, NULL, NULL);
    if (id2 != NULL) {

        timerDelay = 3000U;

        status = osTimerStart(id2, timerDelay);
        if (status != osOK) {
            printf("Failed to start Timer2!\n");
        }
    }
}

APP_FEATURE_INIT(TimerExample);
